<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="java.sql.ResultSet" %><%--
  Created by IntelliJ IDEA.
  User: 吧
  Date: 2020/12/1
  Time: 14:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>查看教师信息</title>
</head>
<link rel="stylesheet" href="css/bootstrap.css">

<script src="js/bootstrap.bundle.js"></script>
<script src="js/bootstrap.js"></script>
<script src="js/jquery.min.js"></script>
<style>



   .row
    {
        width: 80%;
    }
</style>
<%
    Class.forName("com.mysql.jdbc.Driver");
    String url="jdbc:mysql://localhost:3306/lixiuying";
    Connection connection= DriverManager.getConnection(url,"root","root");
    String sql="select * from teacher ";
    PreparedStatement pstm=connection.prepareStatement(sql);
    ResultSet rs=pstm.executeQuery();
    if(session.getAttribute("username")!=null)
    {

    }
    else
    {
        response.sendRedirect("LogOn.jsp");
    }
%>
<body background="5.jpg">
<div align="center">
    <div class="row clearfix">
        <div class="col-md-12 column" align="center">
            <div align="right"><form  action="SelectNewsById.jsp"><input type="text" value="按编号查找教师信息" name="id"><input type="submit" value="查找"></form></div>
            <h2 align="center">欢迎登陆！</h2>
            <div align="left"> <a href="InsertNews.jsp" style="text-decoration: none; color:black;" ><font size="5">插入</font></a></div>
            <table class="table table-hover table-striped">

                <thead>
                <tr>
                    <th>
                        编号
                    </th>
                    <th>
                        姓名
                    </th>
                    <th>
                        年龄
                    </th>
                    <th>
                        性别
                    </th>
                    <th>
                        电话
                    </th>
                    <th>
                        邮箱
                    </th>
                    <th>
                        地址
                    </th>

                    <th>
                        操作
                    </th>

                </tr>
                </thead>
                <tbody>
                <%
                    while( rs.next())
                    {
                        out.print("<tr>");
                        out.print(
                                "<td>"+rs.getString("id")+
                                        "</td><td>"+rs.getString("name")+
                                        "</td><td>"+rs.getInt("age")+
                                        "</td><td>"+rs.getInt("sex")+
                                        "</td><td>"+rs.getString("tel")+
                                        "</td><td>"+rs.getString("email")+
                                        "</td><td>"+rs.getString("address")+
                                        "</td><td COLSPAN=2><a href='DeleteNews.jsp?id="+rs.getString("id")+"'>删除</a>"
                                        +"&nbsp;&nbsp;&nbsp;&nbsp;<a href='UpdateNews.jsp?id="+rs.getString("id")+"'>修改</a>"+"</td>");
                        out.print("</tr>");

                    }%>

                </tbody>
            </table>
        </div>
    </div>
</div>
</body>
</html>
